using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using Aga.Psad.Mvc.Models.Visualizador;
using Aga.Psad.Backend.Repositories;
using Aga.Psad.Backend.Entities;
using System.IO;
using Aga.Psad.Common;
using System.Web.Security;
using System.Web.UI;
using MvcMembership;
using Aga.Psad.Mvc.Models;
using PagedList;

namespace Aga.Psad.Mvc.Controllers
{
    [Authorize(Roles = 
        UserAdministrationController.ROLE_VISUALIZADOR + "," +
        UserAdministrationController.ROLE_DECLARANTE + "," +
        UserAdministrationController.ROLE_IMPO_EXPO)]
    public class VisualizadorController : GuardaDocumentalController
    {
        public override string ControllerName
        {
            get { return "Visualizador"; }
        }

        public VisualizadorController()
        {
            ViewData["Menu"] = "desp";
        }
        [Authorize]
        public ActionResult Buscar(string e, string d, string i, int? index)
        {
            FiltroBusquedaViewModel model = BuscarDespachos(e, d, i, index);

            return View(model);
        }

        [Authorize]
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Buscar(FormCollection collection)
        {
            try
            {
                FiltroBusquedaViewModel model = new FiltroBusquedaViewModel(true);

                UpdateModel(model);

                BuscarDespachos(0, model);

                return View(model);
            }
            catch (Exception ex)
            {
                return ShowError(ex);
            }
        }

    }
}
